package com.example.controller;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * controller
 *
 * @author Chengfei
 * @date 2020/8/21 20:52
 */

@RestController
@ConfigurationProperties(prefix = "person")
public class HelloController {
    //获取数据方法1  @Value
/*    @Value("${name}")
    private String name;
    @Value("${person.name}")
    private String name2;
    @Value("${address[0]}")
    private String address;
    @Value("${msg1}")
    private String msg1;
    @Value("${msg2}")
    private String msg2;*/

    private String name;

    public void setName(String name) {
        this.name = name;
    }

    // Evironment
/*
    @Autowired
    private Environment env;
*/


    @RequestMapping("/hello")
    public String hello() {

/*        System.out.println(name);
        System.out.println(name2);
        System.out.println(address);
        System.out.println(msg1);
        System.out.println(msg2);*/

        System.out.println(name);

/*        System.out.println(env.getProperty("person.name"));
        System.out.println(env.getProperty("address[0]"));*/


        return "hello spring Boot!";
    }
}
